/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.UIManager;


public class GUI {
	// "Construtor" estático
	static {
		// Usar o "LookAndFeel" do sistema
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception ex) {
			// Ignorar excepções
		}

		// Alterar o texto dos botões das caixas de diálogo
		UIManager.put("OptionPane.cancelButtonText", "Cancelar");
		UIManager.put("OptionPane.okButtonText", "Ok");
		UIManager.put("OptionPane.yesButtonText", "Sim");
		UIManager.put("OptionPane.noButtonText", "Não");
	}

	static public void centerWindowOnScreen(JFrame window) {
		int width, height;

		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		width = screen.width / 2 - window.getWidth() / 2;
		height = screen.height / 2 - window.getHeight() / 2;

		window.setLocation(width, height);
	}

	static public void setDefaultButton(JFrame window, JButton button) {
		window.getRootPane().setDefaultButton(button);
	}

	static public String getTime() {
		// Obter a data actual
		DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.S");
        Date date = new Date();
        return dateFormat.format(date);
	}
}
